﻿using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入n:");
            int n = Convert.ToInt32(Console.ReadLine());
            //1.   5! = 5*4*3*2*1 
            fac(n);
           sumFac(n);
            Console.WriteLine(sumFac(n));
        }

        //n!
        static int fac(int n)
        {
            int acc = 1; int sum = 0;
            for (int i = 1; i <= n; i++)
            {
                acc *= i;
                sum += acc;
            }
            return sum;
        }

        //2.求阶乘的和
        static int sumFac(int n)
        {
            int sum = 0;
            for (int i = 1; i <= n; i++)
            {
                sum += fac(i);
            }
            return sum;
        }

    }

}
